from typing import Any, Optional

from flask import jsonify
from werkzeug import Request
from werkzeug.exceptions import HTTPException


class BaseHTTPException(HTTPException):
    error_code: str = "unknown"
    data: Optional[dict] = None

    def __init__(self, description=None, response=None):
        super().__init__(description, response)

        self.data = {
            "code": self.error_code,
            "message": self.description,
            "status": self.code,
        }

    # def get_response(self, environ: dict[str, Any] | Request | None = None, scope: dict[str, Any] | None = None) -> Any:
    #     if self.data:
    #         return jsonify(self.data),self.code
    #     return super().get_response(environ, scope)